package main

import (
	"fmt"
	"net/http"
)

func main()  {
	//绑定路由
	http.HandleFunc("/",indexHandler)
	http.HandleFunc("/home",homeHandler)

	err := http.ListenAndServe("localhost:9000",nil)
	fmt.Println(err)
}

// 参数 r --- 接收到的客户端请求信息
// 	   w --- 响应给客户端的信息
func indexHandler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("这是首页"))
}

func homeHandler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("这是home"))
}
